# 深拷贝和浅拷贝

print("==================================浅拷贝==================================")
a = [12, 1, 45]
b = a
print("a", a)
print("b", b)
a.append("po")
print("追加后的值")
print("a", a)
print("b", b)
print("浅拷贝内存地址是否相同:", id(a) == id(b))

print("==================================半深拷贝==================================")
aa = [12, 33, 66]
bb = aa.copy()
print("aa", aa)
print("bb", bb)
print("追加后的值")
aa.append("o0o0")
print("aa", aa)
print("bb", bb)
print("深拷贝内存地址是否相同:", id(aa) == id(bb))

# 存在嵌套集合时是半深拷贝
print("嵌套集合")
aa1 = [11, 22, 33, [55, 66]]
bb1 = aa1.copy()
print("aa1", aa1)
print("bb1", bb1)

print("嵌套外追加")
aa1.append("99")
print("aa1", aa1)
print("bb1", bb1)

print("嵌套内追加")
aa1[3].append("9")
print("aa1", aa1)
print("bb1", bb1)
print("变成了浅拷贝")

print("==================================完全深拷贝==================================")
import copy

l = [1, 2, 3, [23, 44]]
k = copy.deepcopy(l)
print("l", l)
print("k", k)

print("嵌套内追加")
l[3].append("d")
print("l", l)
print("k", k)
print("完全深拷贝")
